package com.haizhi.crm.search.constant;

import java.util.EnumSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by chengmo on 2018/6/14.
 */
public enum AtlasType {
    STOCK_RIGHT(1),
    INVESTMENT_ABROAD(2),
    KEY_PERSONNEL(3),
    GUARANTEE(4),
    TRANSFER(5),
    CONCERT(6),
    ACTUAL_CONTROLLER(7),
    COMPOSITE(8),
    UNKNOWN(-1);

    private static final Map<Integer, AtlasType> LOOKUP = new ConcurrentHashMap<>(9);

    static {
        for (AtlasType type : EnumSet.allOf(AtlasType.class)) {
            LOOKUP.put(type.serialNumber, type);
        }
    }

    private int serialNumber;

    AtlasType(int serialNumber) {
        this.serialNumber = serialNumber;
    }

    public static AtlasType from(int serialNumber) {
        if (serialNumber < 0) {
            return AtlasType.UNKNOWN;
        }
        AtlasType type = LOOKUP.get(serialNumber);
        if (type == null) {
            return AtlasType.UNKNOWN;
        }
        return type;
    }
}
